package com.example.haoyundaoyonghu.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;


import com.example.haoyundaoyonghu.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class ShowDialog extends Dialog {


    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.tv_msg)
    TextView tvMsg;
    @BindView(R.id.ll_btn_cancel)
    LinearLayout llBtnCancel;
    @BindView(R.id.ll_btn_ok)
    LinearLayout llBtnOk;
    @BindView(R.id.ll_bottom)
    LinearLayout llBottom;

    private View view;
    private Context context;
    private String tit;
    private String message;


    public ShowDialog(@NonNull Context context) {
        super(context, R.style.Theme_Light_PayDialog);
        this.context = context;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        view = LayoutInflater.from(context).inflate(R.layout.dialog_my_tips, null);
        setContentView(view);
        ButterKnife.bind(this, view);
        tvTitle.setText(tit);
        tvMsg.setText(message);
    }


    private View.OnClickListener onClickListener;

    public void setShowDialog(String tit, String message, View.OnClickListener onClickListener) {
        this.tit = tit;
        this.message = message;
        this.onClickListener = onClickListener;


    }


    @OnClick({R.id.ll_btn_cancel, R.id.ll_btn_ok})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.ll_btn_cancel:
                dismiss();
                if (onClickListener == null) {
                    onClickListener.onClick(null);
                }
                break;
            case R.id.ll_btn_ok:
                dismiss();
                if (onClickListener != null) {
                    onClickListener.onClick(view);
                }
                break;
        }
    }
}
